define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user.user_bill/index',
        add_url: 'user.user_bill/add',
        edit_url: 'user.user_bill/edit',
        delete_url: 'user.user_bill/delete',
        export_url: 'user.user_bill/export',
        modify_url: 'user.user_bill/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id'},
                    {field: 'uid', title: '用户名称',templet:function (res) {
                            return '<label>'+res.userBill.username+'</label>'
                        }},
                    {field: 'pm', title: '状态',templet: function (res) {
                        if (res.pm == 0){
                            return '<label>支出</label>'
                        }else {
                            return '<label>收入</label>'
                        }
                        }},
                    {field: 'title', title: '账单标题'},
                    {field: 'number', title: '账单明细金额',templet:function (res) {
                            if (res.pm == 0){
                                return '<label style="color: red">'+ '-'+ res.number+'</label>'
                            }else {
                                return '<label style="color: #2ecc71">'+res.number+'</label>'
                            }
                        }},
                    {field: 'create_time', title: '创建时间'},

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});